home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-10-25 | 4.8 KB | 148 lines | [TEXT/MPS ] |
- {[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n+]}
- { Nothing.p }
- { Copyright © 1986-1990 by Apple Computer, Inc. All rights reserved.}
-
- {[f-]}
- {
- This is a very small sample application which can save files on disk and can
- print.
-
- The application's windows each contain the word 'MacApp', in large type, and
- are framed by a large gray border.
-
- Documents can be saved on disk and later reopened, but the only
- document-specific information saved in the disk file is the Print information,
- which means that if you set print specifications using the Page Setup dialog
- for a document, and then save the document (using Save As or Save a Copy),
- those specifications are saved on disk, and when you reopen the document
- you will find those same print specifications holding for the document.
-
-
- All applications that create views procedurally need to reimplement at least three
- methods:
-
- TApplication.DoMakeDocument -- Launches the appropriate type of Document object
- TDocument.DoMakeViews -- Launches the appropriate type of View and window objects
- TView.Draw -- Draws the contents of a view
-
- This application, however, consists of the reimplementation of only one method -
- TView.Draw. This is possible since the view is created from templates; MacApp
- supplies the default 'view' resource. So in a sense this application is the smallest
- possible MacApp application.
- }
- {[f+]}
-
- PROGRAM UNothing;
-
- {$MC68020-} { The main program must be universal code }
- {$MC68881-}
-
- USES
- { • MacApp }
- UMacApp,
-
- { • Building Blocks }
- UPrinting,
-
- { • Implementation Use }
- Fonts;
-
- CONST
-
- kSignature = 'SS01'; { Application signature}
- kFileType = 'SF01'; { File-type code used for document files
- created by this application}
-
- TYPE
-
- TNothingApplication = OBJECT (TApplication)
-
- PROCEDURE TNothingApplication.INothingApplication(itsMainFileType: OSType);
- { Initializes the application and globals. }
- END;
-
- TDefaultView = OBJECT (TView)
-
- PROCEDURE TDefaultView.Draw(area: Rect); OVERRIDE;
- { Draws the view seen in the window. Every nonblank view MUST override this method. }
- END;
-
- { I M P L E M E N T A T I O N }
-
- {--------------------------------------------------------------------------------------------------}
-
- PROCEDURE TNothingApplication.INothingApplication(itsMainFileType: OSType);
-
- BEGIN
- IApplication(itsMainFileType);
-
- RegisterStdType('TDefaultView', kStdDefaultView); { So my view will be substituted when
- MacApp® creates the "default view".
- More complex documents and views will
- require overriding
- TApplication.DoMakeDocument,
- TDocument.DoMakeviews and (if not using
- template views) TDocument.DoMakeWindows. }
- { So the linker doesn't dead strip class info }
- IF gDeadStripSuppression THEN
- IF Member(TObject(NIL), TDefaultView) THEN ;
- END;
-
- {--------------------------------------------------------------------------------------------------}
-
- PROCEDURE TDefaultView.Draw(area: Rect); OVERRIDE;
-
- VAR
- itsQDExtent: Rect;
-
- BEGIN
- PenNormal;
- PenSize(10, 10);
- PenPat(dkGray);
-
- GetQDExtent(itsQDExtent); { We know its extent always fits in
- QuickDraw coordinates. }
- FrameRect(itsQDExtent); { Draw a dark gray frame}
-
- {Set font and size for subsequent display in the window}
- SetPortTextStyle(gApplicationStyle);
- TextSize(72);
-
- InsetRect(itsQDExtent, 30, 20);
- MADrawString(AtStr('MacApp®'), itsQDExtent, teJustSystem); { Draw the word 'MacApp®' in large
- type using our handy international compatible
- DrawString substitute. }
- PenNormal; { Restore the pen state. }
-
- INHERITED Draw(area);
- END;
-
- {--------------------------------------------------------------------------------------------------}
- { T H E M A I N P R O G R A M }
-
- VAR
-
- gNothingApplication: TNothingApplication; { The application object }
-
- BEGIN
- InitUMacApp(8); { Initialize MacApp; 8 calls to MoreMasters
- We will rely on InitUMacApp automatically
- initializing the toolbox for us (InitToolBox)
- and making sure we can run in the current
- environment (ValidateConfiguration/StdAlert).
- This approach while easier doesn't give you
- validation early enough for some needs. See
- the other examples for alternate was.
- If you will be using a splash screen see the
- CALC example for details. }
- InitUPrinting; { Initialize the UPrinting unit:}
-
- New(gNothingApplication); { Allocate a new TNothingApplication
- object }
- FailNIL(gNothingApplication);
- gNothingApplication.INothingApplication(kFileType); { Initialize that new object:}
-
- gNothingApplication.Run; { Run the application. When it's done,
- exit.}
- END.
-